package com.doublefish.doublefishrobot.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.doublefish.doublefishrobot.R;

public class PrivacyDialog  extends Dialog {

    Context mContext;

    private TextView okTv;
    private TextView rejectTv;
    private TextView privacyTv;
    private OnBtnClickListener onBtnClickListener;

    public PrivacyDialog(Context context, OnBtnClickListener listener) {
        super(context,  R.style.dialog);

        this.mContext = context;
        this.onBtnClickListener = listener;
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_privacy);
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        initView();
    }

    private void initView() {
        privacyTv = findViewById(R.id.tv_privacy);
        okTv = findViewById(R.id.tv_ok);
        rejectTv = findViewById(R.id.tv_reject);

        privacyTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onBtnClickListener != null) {
                    onBtnClickListener.onPrivacyBtnClick();
                }
            }
        });

        okTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
                if (onBtnClickListener != null) {
                    onBtnClickListener.onConfirmBtnClick();
                }
            }
        });

        rejectTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
                if (onBtnClickListener != null) {
                    onBtnClickListener.onCancelBtnClick();
                }
            }
        });
    }

    public interface OnBtnClickListener {
        void onPrivacyBtnClick();
        void onConfirmBtnClick();
        void onCancelBtnClick();
    }
}
